﻿using System;
using System.Collections;
using System.Web;
using System.Web.Security;

namespace ProductionAnalysis.Web
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Hashtable h = (Hashtable)Application["online"];
            //IDictionaryEnumerator e1 = h.GetEnumerator();
            //ArrayList al = new ArrayList();
            //while (e1.MoveNext())
            //{
            //    Response.Write("<h3>" + e1.Key.ToString() + "</h3>");
            //    Response.Write("<h3>" + Request.UserHostAddress + "</h3>");
            //}
            Check();
            //Response.Write("<h3>" + Membership.GetUser().LastActivityDate.ToString() + "</h3>");
        }

        private void Check()
        {
            if (HttpContext.Current != null)
            {
                if (Roles.IsUserInRole("Guest"))
                {
                    this.P1.Visible = true;
                    this.P2.Visible = true;
                    this.P3.Visible = true;
                    this.P8.Visible = true;
                }
                if (Roles.IsUserInRole("Operator"))
                {
                    this.P1.Visible = true;
                }
                if (Roles.IsUserInRole("StockKeeper"))
                {
                    this.P20.Visible = true;
                }
                if (Roles.IsUserInRole("DebugTest_Batch_Add"))
                {
                    this.P5.Visible = true;
                }
                if (Roles.IsUserInRole("ProductTypeInfo_Export"))
                {
                    this.P7.Visible = true;
                }
                if (Roles.IsUserInRole("Airtightnesser"))
                {
                    this.P17.Visible = true;
                }
                if (Roles.IsUserInRole("Info Manager"))
                {
                    this.P7.Visible = true;
                }
                if (Roles.IsUserInRole("Aginger"))
                {
                    this.P4.Visible = true;
                }
                if (Roles.IsUserInRole("Packer"))
                {
                    this.P4.Visible = true;
                    this.P5.Visible = true;
                    this.P6.Visible = true;
                    this.P12.Visible = true;
                    this.P13.Visible = true;
                    this.P14.Visible = true;          
                    this.P18.Visible = true;
                    this.P19.Visible = true;
                }
                if (Roles.IsUserInRole("IT Engineer"))
                {
                    this.P8.Visible = true;
                }
                if (Roles.IsUserInRole("Repair Manager"))
                {
                    this.P16.Visible = true;
                }
                if (Roles.IsUserInRole("返修_返修记录录入"))
                {
                    this.P16.Visible = true;
                }
                if (Roles.IsUserInRole("返修_成品条码替换"))
                {
                    this.P16.Visible = true;
                }
                if (Roles.IsUserInRole("Quality Operator"))
                {
                    this.P4.Visible = true;
                    this.P6.Visible = true;
                    this.P12.Visible = true;
                    this.P13.Visible = true;
                    this.P14.Visible = true;
                }
                if (Roles.IsUserInRole("Quality Engineer"))
                {
                    this.P1.Visible = true;
                    this.P2.Visible = true;
                    this.P3.Visible = true;
                    this.P4.Visible = true;
                    this.P5.Visible = true;
                    this.P7.Visible = true;
                    this.P12.Visible = true;
                    this.P13.Visible = true;
                    this.P14.Visible = true;
                    this.P15.Visible = true;
                    this.P16.Visible = true;
                    this.P17.Visible = true;
                    this.P18.Visible = true;
                    this.P19.Visible = true;
                }
                if (Roles.IsUserInRole("Manager"))
                {
                    this.P1.Visible = true;
                    this.P2.Visible = true;
                    this.P3.Visible = true;
                    this.P4.Visible = true;
                    this.P5.Visible = true;
                    this.P6.Visible = true;
                    this.P7.Visible = true;
                    this.P8.Visible = true;
                    this.P9.Visible = true;
                    //this.P10.Visible = true;
                    this.P12.Visible = true;
                    this.P13.Visible = true;
                    this.P14.Visible = true;
                    this.P15.Visible = true;
                    this.P16.Visible = true;
                    this.P17.Visible = true;
                    this.P18.Visible = true;
                    this.P19.Visible = true;
                    this.P20.Visible = true;
                }
                if (Roles.IsUserInRole("Administrators"))
                {
                    this.P1.Visible = true;
                    this.P2.Visible = true;
                    this.P3.Visible = true;
                    this.P4.Visible = true;
                    this.P5.Visible = true;
                    this.P6.Visible = true;
                    this.P7.Visible = true;
                    this.P8.Visible = true;
                    this.P9.Visible = true;
                    this.P10.Visible = true;
                    this.P11.Visible = true;
                    this.P12.Visible = true;
                    this.P13.Visible = true;
                    this.P14.Visible = true;
                    this.P15.Visible = true;
                    this.P16.Visible = true;
                    this.P17.Visible = true;
                    this.P18.Visible = true;
                    this.P19.Visible = true;
                    this.P20.Visible = true;
                }
            }
        }
    }
}